#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int i=0,j,k=0,count=1;
    for(i=0;i<=1000;i++){
        k=0;
        for(j=2;j<=i/2;j++){
            if(0==i%j)k++;
            }
            if(k==0){

                printf("%4d ",i);
                count++;

                if(count%5!=0)continue;



                cout<<endl;

            }

    }

    return 0;
}
